#include "namedpipe.hpp"

int main()
{
    My_Named_Pipe::Client cli("./fifo");
    cli._open();
    cli._write();
    cli._close();
    return 0;
}



int client()
{
    // 打开文件
    int openret = open(FIFO_PATHNAME, O_WRONLY);
    if (openret == -1)
    {
        ERROR_MESSAGE("open");
    }
    std::cout << "写打开文件" << std::endl;
    std::cout << "开始写入->" << std::endl;

    // 写文件
    while (1)
    {
        char buffer[BUFF_SIZE] = {0};
        std::cin >> buffer;
        ssize_t writeret = write(openret, buffer, sizeof(buffer));
        // std::cout<< buffer << std::endl;
        if (strcmp(buffer, "close") == 0)
        {
            break;
        }
    }

    // 关闭文件
    close(openret);
    std::cout << "关闭文件" << std::endl;

    return 0;
}
